|
|
 |
|
|
|
|
.EmpID = 1
.FirstName = "Bill"
.LastName = "Gates"
.Salary = 100000
strValue = .EmpID
strValue = .FirstName
strValue = .LastName
strValue = .Salary
Next
End With |
|
|
|
|
|
|
|
|
You would think that because the code does not need to perform a lookup on the oEmp variable, it would be able to go directly to the location where the properties are in their symbol table. However, in these tests, there was only a slight increase in speed using With...End With. |
|
|
|
|
|
|
|
|
Hide Controls When They're Loading |
|
|
|
|
|
|
|
|
When youre loading any list-type controls, its a good idea to turn off the redrawing of the control until its fully populated with the data. On list boxes and combo boxes, there is no property to do this, so you need to set the Visible property to False. Heres an example: |
|
|
|
 |
|
|
|
|
lstItems.Visible = True
lstItems.Clear
For intLoop = 0 To 1000
lstItems.AddItem "Loop " & intLoop
Next |
|
|
|
|
|
|
|
|
In the next version, the Visible property is set to False, the list is loaded, and then the Visible property is set back to True: |
|
|
|
 |
|
|
|
|
lstItems.Visible = False
lstItems.Clear
For intLoop = 0 To 1000
lstItems.AddItem "Loop" & intLoop
Next
lstItems.Visible = True |
|
|
|
|
|
|
|
|
In my tests, this runs approximately 75 percent faster. Heres the reason for the speed difference: Every time an item is added to a list box, the visible portion of that list box has to be redrawn, and this takes a lot of time. |
|
|
|
|
|